﻿using System;
using System.Collections.Generic;
using System.Text;

namespace VkSample66
{
    public class SkyData
    {
        public float[] Data { get; set; }

        public uint VCount { get; set; }

        private Random Random = new Random();

        private const int UNIT_SIZE = 2000;

        public void GenSkyData(int vCountIn)
        {
            VCount = (uint)vCountIn;
            Data = new float[VCount * 6];
            for(int i = 0; i < VCount; i++)
            {
                double angleTempJD = Math.PI * 2 * random();
                double angleTempWD = Math.PI * (random() - 0.5f);
                Data[i * 6 + 0] = (float)(UNIT_SIZE * Math.Cos(angleTempWD) * Math.Sin(angleTempJD)); //顶点位置 X 分量
                Data[i * 6 + 1] = (float)(UNIT_SIZE * Math.Sin(angleTempWD)); //顶点位置 Y 分量
                Data[i * 6 + 2] = (float)(UNIT_SIZE * Math.Cos(angleTempWD) * Math.Cos(angleTempJD)); //顶点位置 Z 分量
                Data[i * 6 + 3] = 1.0f; //颜色值 R 分量
                Data[i * 6 + 4] = 1.0f; //颜色值 G 分量
                Data[i * 6 + 5] = 1.0f; //颜色值 B 分量
            }
        }

        private float random() => Random.Next() % 30000 / 30000.0f;
    }
}
